from core.models import UserProfile
from django.contrib.auth.models import User

## FIXME: - guardar la suscripcion elegida en UserProfile
##        - revisar clase nueva usersmanager

class UsersManager:
    def __init__(self):
        pass
        
    def get(self, _email):
        '''Get single user profile by email'''
        try:
            oUserProfile = UserProfile.objects.get(user.email=_email)
            return oUserProfile
        except:
            return 0

    def put(self, _User):
        ''' Create new user profile'''
        try:
            oUserProfile = UserProfile.objects.get(user.email=_User.email)
        except:
            oUserProfile = UserProfile.objects.create(user.email=_User.email, user.nickname=_User.nickname,'')
            oUserProfile.save()
        if _User.profile.newsletter == "False" :
            oUserProfile.subscribe.newsletter = False
        else:
            oUserProfile.subscribe.newsletter = True
        oUserProfile.save()
        return 1



